<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <div id="test">
    FirstName: <input type="text" v-model="firstName"><br>
    LastName: <input type="text" v-model="lastName"><br>
    FullName(双向): <input type="text" v-model="fullName">
  </div>

  <script src="../js/vue.js"></script>
  <script>
    const vm = new Vue({
      el: "#test",
      data: {
        firstName:'A',
        lastName:'B',
        fullName4:'A-B'
      },
      computed:{
        fullName:{
            get(){
                return this.firstName+'-'+this.lastName
            },
            set(value){
                const names = value.split('-')

                this.firstName = names[0]
                this.lastName = names[1]
            }
        }
      }
    })
    
  </script>
</body>
</html>